import http from '@/utils/http'

export default {
  // 小程序登录
  login(body) {
    const inviteUserId = uni.getStorageSync('inviteUserId')
    if (inviteUserId) body.inviteUserId = inviteUserId

    const indexQuery = uni.getStorageSync('indexQuery')
    if (indexQuery) body.indexQuery = indexQuery

    return http({
      method: 'POST',
      showLoading: '登录中...',
      url: '/wechat/mini/login',
      data: body
    })
  },

  // 绑定手机号
  bindMobile(body, options) {
    const { jsCode, encryptedData, iv } = body
    return http({
      method: 'POST',
      showLoading: '绑定中...',
      url: '/wechat/mini/bind-mobile',
      // needLogin: true,
      showLoading: true,
      bindConstellation: false,
      data: {
        jsCode,
        encryptedData,
        iv
      },
      ...options
    })
  }
}
